package com.csj.DesignPattern.spring.example.controller;


import com.csj.DesignPattern.spring.customSpring.framework.factory.ClassPathXmlApplicationContext;
import com.csj.DesignPattern.spring.example.service.UserService;

public class UserController {
    public static void main(String[] args) throws Exception {
        //BeanFactory是spring-beans和spring-core的核心接口，实现了控制反转和依赖注入
        //懒加载，即创建容器时不会实例化Bean，只有在Bean被使用时才会进行实例化（new或反射）
        //BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
        //ApplicationContext是spring-context的核心接口，是BeanFactory的扩展接口，扩展了bean的生命周期管理功能、框架事件、事件透明化等功能
        //ApplicationContext实例化后会对所有的单利Bean进行实例化并装配依赖关系
        ClassPathXmlApplicationContext context  = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = context.getBean("userService", UserService.class);
        userService.save();
    }
}
